//TO-DO: invalidate doit when nothing is done.
import java.util.*;
import javax.swing.*;

import java.awt.*;
import java.awt.event.*;

class MortgageDialog extends JDialog implements ActionListener{
	JButton doIt, cancel;
	JPanel panel;
	int startingCash;
	IntContainer totalGain;
	static int remainingCash;
	Player currentPlayer;
	int returnValue;
	
	ArrayList<IntContainer> NumHouseDarkPurple;
	ArrayList<IntContainer> NumHouseLightBlue;
	ArrayList<IntContainer> NumHouseLightPurple;
	ArrayList<IntContainer> NumHouseOrange;
	ArrayList<IntContainer> NumHouseRed;
	ArrayList<IntContainer> NumHouseYellow;
	ArrayList<IntContainer> NumHouseGreen;
	ArrayList<IntContainer> NumHouseDarkBlue;
	
	ArrayList<BooleanContainer> hasHotelDarkPurple;
	ArrayList<BooleanContainer> hasHotelLightBlue;
	ArrayList<BooleanContainer> hasHotelLightPurple;
	ArrayList<BooleanContainer> hasHotelOrange;
	ArrayList<BooleanContainer> hasHotelRed;
	ArrayList<BooleanContainer> hasHotelYellow;
	ArrayList<BooleanContainer> hasHotelGreen;
	ArrayList<BooleanContainer> hasHotelDarkBlue;
	
	ArrayList<BooleanContainer> isMortgagedDarkPurple;
	ArrayList<BooleanContainer> isMortgagedLightBlue;
	ArrayList<BooleanContainer> isMortgagedLightPurple;
	ArrayList<BooleanContainer> isMortgagedOrange;
	ArrayList<BooleanContainer> isMortgagedRed;
	ArrayList<BooleanContainer> isMortgagedYellow;
	ArrayList<BooleanContainer> isMortgagedGreen;
	ArrayList<BooleanContainer> isMortgagedDarkBlue;
	ArrayList<BooleanContainer> isMortgagedUtility;
	ArrayList<BooleanContainer> isMortgagedRailroad;
	
	IntContainer NumHouseDarkPurple1, NumHouseDarkPurple2, NumHouseLightBlue1, NumHouseLightBlue2, NumHouseLightBlue3,
	NumHouseLightPurple1, NumHouseLightPurple2, NumHouseLightPurple3, NumHouseOrange1, NumHouseOrange2, NumHouseOrange3,
	NumHouseRed1, NumHouseRed2, NumHouseRed3, NumHouseYellow1, NumHouseYellow2, NumHouseYellow3, NumHouseGreen1, NumHouseGreen2,
	NumHouseGreen3, NumHouseDarkBlue1, NumHouseDarkBlue2;
	
	BooleanContainer hasHotelDarkPurple1, hasHotelDarkPurple2, hasHotelLightBlue1, hasHotelLightBlue2, hasHotelLightBlue3,
	hasHotelLightPurple1, hasHotelLightPurple2, hasHotelLightPurple3, hasHotelOrange1, hasHotelOrange2, hasHotelOrange3,
	hasHotelRed1, hasHotelRed2, hasHotelRed3, hasHotelYellow1, hasHotelYellow2, hasHotelYellow3, hasHotelGreen1, hasHotelGreen2,
	hasHotelGreen3, hasHotelDarkBlue1, hasHotelDarkBlue2;
	
	BooleanContainer isMortgagedDarkPurple1, isMortgagedDarkPurple2, isMortgagedLightBlue1, isMortgagedLightBlue2, isMortgagedLightBlue3,
	isMortgagedLightPurple1, isMortgagedLightPurple2, isMortgagedLightPurple3, isMortgagedOrange1, isMortgagedOrange2, isMortgagedOrange3,
	isMortgagedRed1, isMortgagedRed2, isMortgagedRed3, isMortgagedYellow1, isMortgagedYellow2, isMortgagedYellow3, isMortgagedGreen1, isMortgagedGreen2,
	isMortgagedGreen3, isMortgagedDarkBlue1, isMortgagedDarkBlue2;
	
	
	
	MortgageDialog(Player p)
	{
		NumHouseDarkPurple = new ArrayList(2);
		NumHouseLightBlue = new ArrayList(3);
		NumHouseLightPurple = new ArrayList(3);
		NumHouseOrange = new ArrayList(3);
		NumHouseRed = new ArrayList(3);
		NumHouseYellow = new ArrayList(3);
		NumHouseGreen = new ArrayList(3);
		NumHouseDarkBlue = new ArrayList(3);
		
		hasHotelDarkPurple = new ArrayList(2);
		hasHotelLightBlue = new ArrayList(3);
		hasHotelLightPurple = new ArrayList(3);
		hasHotelOrange = new ArrayList(3);
		hasHotelRed = new ArrayList(3);
		hasHotelYellow = new ArrayList(3);
		hasHotelGreen = new ArrayList(3);
		hasHotelDarkBlue = new ArrayList(2);
		
		isMortgagedDarkPurple = new ArrayList(2);
		isMortgagedLightBlue = new ArrayList(3);
		isMortgagedLightPurple = new ArrayList(3);
		isMortgagedOrange = new ArrayList(3);
		isMortgagedRed = new ArrayList(3);
		isMortgagedYellow = new ArrayList(3);
		isMortgagedGreen = new ArrayList(3);
		isMortgagedDarkBlue = new ArrayList(2);
		isMortgagedRailroad = new ArrayList(4);
		isMortgagedUtility = new ArrayList(2);
		
		//this.setUndecorated(true);
		setBackground(Color.green);
		currentPlayer = p;
		
		//currentPlayer = new Player();
		
		
		/*
		currentPlayer.addNewProperty("MediterraneanAve");
		currentPlayer.addNewProperty("BalticAve");//they're purple color, only 2 properties
		//this.currentPlayer.buildHouse("MediterraneanAve", 4);
		//this.currentPlayer.buildHouse("BalticAve", 4);
		//this.currentPlayer.buildHotel("MediterraneanAve");
		//this.currentPlayer.mortgage("MediterraneanAve");
		//this.currentPlayer.mortgage("BalticAve");
		
		this.currentPlayer.addNewProperty("NewYorkAve");
		this.currentPlayer.addNewProperty("TennesseeAve");
		this.currentPlayer.addNewProperty("StJamesPlace");
		this.currentPlayer.buildHouse("NewYorkAve", 4);
		this.currentPlayer.buildHouse("TennesseeAve", 4);
		this.currentPlayer.buildHouse("StJamesPlace", 3);
		
		this.currentPlayer.addNewProperty("OrientalAve");
		this.currentPlayer.addNewProperty("VermontAve");
		this.currentPlayer.addNewProperty("ConnecticutAve");
		this.currentPlayer.buildHouse("OrientalAve", 2);
		this.currentPlayer.buildHouse("VermontAve", 1);
		this.currentPlayer.buildHouse("ConnecticutAve", 2);
		
		this.currentPlayer.addNewProperty("PacificAve");
		this.currentPlayer.addNewProperty("NorthCarolinaAve");
		this.currentPlayer.addNewProperty("PennsylvaniaAve");
		this.currentPlayer.buildHouse("PacificAve", 0);
		this.currentPlayer.buildHouse("NorthCarolinaAve", 0);
		this.currentPlayer.buildHouse("PennsylvaniaAve", 0);
		this.currentPlayer.mortgage("PacificAve");
		this.currentPlayer.mortgage("NorthCarolinaAve");
		this.currentPlayer.mortgage("PennsylvaniaAve");
		
		currentPlayer.addNewProperty("ParkPlace");
		currentPlayer.addNewProperty("Boardwalk");
		
		currentPlayer.addNewProperty("WaterWorks");
		currentPlayer.addNewProperty("ElectricCompany");
		
		currentPlayer.addNewProperty("ReadingRailroad");
		currentPlayer.addNewProperty("B&ORailroad");
		currentPlayer.mortgage("ReadingRailroad");
		*/
		returnValue = -1;
		
		 //TESTPart
        System.out.println("Now trying to mortgage. initial cash: " + this.currentPlayer.getCash());
        for(int i = 0; i<this.currentPlayer.getDarkPurpleSize(); i++){
        	String name = this.currentPlayer.getDarkPurpleNameAt(i);
        	System.out.println(name + " has "+ this.currentPlayer.getNumberOfHouses(name));
        	System.out.println(name + " has hotel?: "+ this.currentPlayer.hasHotel(name));
        	System.out.println(name + " is mortgaged?: "+ this.currentPlayer.isMortgaged(name));
        }
        for(int i = 0; i<this.currentPlayer.getLightBlueSize(); i++){
        	String name = this.currentPlayer.getLightBlueNameAt(i);
        	System.out.println(name + " has "+ this.currentPlayer.getNumberOfHouses(name));
        	System.out.println(name + " has hotel?: "+ this.currentPlayer.hasHotel(name));
        	System.out.println(name + " is mortgaged?: "+ this.currentPlayer.isMortgaged(name));
        }
        for(int i = 0; i<this.currentPlayer.getLightPurpleSize(); i++){
        	String name = this.currentPlayer.getLightPurpleNameAt(i);
        	System.out.println(name + " has "+ this.currentPlayer.getNumberOfHouses(name));
        	System.out.println(name + " has hotel?: "+ this.currentPlayer.hasHotel(name));
        	System.out.println(name + " is mortgaged?: "+ this.currentPlayer.isMortgaged(name));
        }
        for(int i = 0; i<this.currentPlayer.getOrangeSize(); i++){
        	String name = this.currentPlayer.getOrangeNameAt(i);
        	System.out.println(name + " has "+ this.currentPlayer.getNumberOfHouses(name));
        	System.out.println(name + " has hotel?: "+ this.currentPlayer.hasHotel(name));
        	System.out.println(name + " is mortgaged?: "+ this.currentPlayer.isMortgaged(name));
        }
        for(int i = 0; i<this.currentPlayer.getRedSize(); i++){
        	String name = this.currentPlayer.getRedNameAt(i);
        	System.out.println(name + " has "+ this.currentPlayer.getNumberOfHouses(name));
        	System.out.println(name + " has hotel?: "+ this.currentPlayer.hasHotel(name));
        	System.out.println(name + " is mortgaged?: "+ this.currentPlayer.isMortgaged(name));
        }
        for(int i = 0; i<this.currentPlayer.getYellowSize(); i++){
        	String name = this.currentPlayer.getYellowNameAt(i);
        	System.out.println(name + " has "+ this.currentPlayer.getNumberOfHouses(name));
        	System.out.println(name + " has hotel?: "+ this.currentPlayer.hasHotel(name));
        	System.out.println(name + " is mortgaged?: "+ this.currentPlayer.isMortgaged(name));
        }
        for(int i = 0; i<this.currentPlayer.getGreenSize(); i++){
        	String name = this.currentPlayer.getGreenNameAt(i);
        	System.out.println(name + " has "+ this.currentPlayer.getNumberOfHouses(name));
        	System.out.println(name + " has hotel?: "+ this.currentPlayer.hasHotel(name));
        	System.out.println(name + " is mortgaged?: "+ this.currentPlayer.isMortgaged(name));
        }
        for(int i = 0; i<this.currentPlayer.getDarkBlueSize(); i++){
        	String name = this.currentPlayer.getDarkBlueNameAt(i);
        	System.out.println(name + " has "+ this.currentPlayer.getNumberOfHouses(name));
        	System.out.println(name + " has hotel?: "+ this.currentPlayer.hasHotel(name));
        	System.out.println(name + " is mortgaged?: "+ this.currentPlayer.isMortgaged(name));
        }
        for(int i = 0; i<this.currentPlayer.getUtilitySize(); i++){
        	String name = this.currentPlayer.getUtilityNameAt(i);
        	System.out.println(name + " is mortgaged?: "+ this.currentPlayer.isMortgaged(name));
        }
        for(int i = 0; i<this.currentPlayer.getRailroadSize(); i++){
        	String name = this.currentPlayer.getRailroadNameAt(i);
        	System.out.println(name + " is mortgaged?: "+ this.currentPlayer.isMortgaged(name));
        }
        
        System.out.println("initial total Wealth" + this.currentPlayer.getTotalWealth());
        System.out.println("initial total houseNum" + this.currentPlayer.getTotalHouseNum());
		 //TESTPart
		
        
        /*Check if the player has some properies that can be mortgeged.
        if every property(land, railroad, util) is mortgaged OR the player 
        doesn't have any property, nothing can be done.*/ 
        
        
		totalGain = new IntContainer(0);
		remainingCash = currentPlayer.getCash();//at first it's same as starting cash
		JLabel totalGainLabel = new JLabel("Total cost: $" + totalGain.intValue());
		JLabel remainingCashLabel = new JLabel("Cash remaining: $" + remainingCash);
		
		
		
		JPanel availableProperties = new JPanel();
    	availableProperties.setLayout(new GridLayout(0,1));    	
    	
    	boolean canMortgageSomeProp = false;/*frag to see if the player has some properies that can be mortgeged.
        if every property(land, railroad, util) is mortgaged OR the player 
        doesn't have any property, nothing can be done.*/
    	if(currentPlayer.getDarkPurpleSize() == 2){
    		for(int i = 0; i < currentPlayer.getDarkPurpleSize(); i++){
    				this.NumHouseDarkPurple.add(new IntContainer(currentPlayer.getNumberOfHouses(currentPlayer.getDarkPurpleNameAt(i))));
    				this.hasHotelDarkPurple.add(new BooleanContainer(currentPlayer.hasHotel(currentPlayer.getDarkPurpleNameAt(i))));
    				this.isMortgagedDarkPurple.add(new BooleanContainer(currentPlayer.isMortgaged(currentPlayer.getDarkPurpleNameAt(i))));
    		}
    	}
    	else if(currentPlayer.getDarkPurpleSize() == 1){
    		this.NumHouseDarkPurple.add(new IntContainer(currentPlayer.getNumberOfHouses(currentPlayer.getDarkPurpleNameAt(0))));
			this.hasHotelDarkPurple.add(new BooleanContainer(currentPlayer.hasHotel(currentPlayer.getDarkPurpleNameAt(0))));
			this.isMortgagedDarkPurple.add(new BooleanContainer(currentPlayer.isMortgaged(currentPlayer.getDarkPurpleNameAt(0))));
			this.NumHouseDarkPurple.add(new IntContainer(0));
			this.hasHotelDarkPurple.add(new BooleanContainer(false));
			this.isMortgagedDarkPurple.add(new BooleanContainer(false));
			}
    	//Now adding the ButtonPanel if the color is complete
    	for(int i = 0; i< this.currentPlayer.getDarkPurpleSize(); i++){
    			String name = currentPlayer.getDarkPurpleNameAt(i);
    			if(currentPlayer.isMortgaged(name) == false)
    				canMortgageSomeProp = true;
    			availableProperties.add(new ButtonsOfPropHouseHotel(currentPlayer, currentPlayer.getDarkPurpleSize(), i, totalGain, remainingCash,  name, currentPlayer.getNumberOfHouses(name),
    					currentPlayer.hasHotel(name), NumHouseDarkPurple.get(0), NumHouseDarkPurple.get(1), new IntContainer(0), totalGainLabel, remainingCashLabel,
    					hasHotelDarkPurple.get(0), hasHotelDarkPurple.get(1), new BooleanContainer(false), isMortgagedDarkPurple.get(0), isMortgagedDarkPurple.get(1),
    					new BooleanContainer(false)));
    		}
    	
    	if(currentPlayer.getLightBlueSize() == 3){
    		for(int i = 0; i < currentPlayer.getLightBlueSize(); i++){
    				this.NumHouseLightBlue.add(new IntContainer(currentPlayer.getNumberOfHouses(currentPlayer.getLightBlueNameAt(i))));
    				this.hasHotelLightBlue.add(new BooleanContainer(currentPlayer.hasHotel(currentPlayer.getLightBlueNameAt(i))));
    				this.isMortgagedLightBlue.add(new BooleanContainer(currentPlayer.isMortgaged(currentPlayer.getLightBlueNameAt(i))));
    		}
    	}
    	
    	if(currentPlayer.getLightBlueSize() == 2){
    		for(int i = 0; i < currentPlayer.getLightBlueSize(); i++){
    				this.NumHouseLightBlue.add(new IntContainer(currentPlayer.getNumberOfHouses(currentPlayer.getLightBlueNameAt(i))));
    				this.hasHotelLightBlue.add(new BooleanContainer(currentPlayer.hasHotel(currentPlayer.getLightBlueNameAt(i))));
    				this.isMortgagedLightBlue.add(new BooleanContainer(currentPlayer.isMortgaged(currentPlayer.getLightBlueNameAt(i))));
    				this.NumHouseLightBlue.add(new IntContainer(0));
    				this.hasHotelLightBlue.add(new BooleanContainer(false));
    				this.isMortgagedLightBlue.add(new BooleanContainer(false));
    		}
    	}
    	else if(currentPlayer.getLightBlueSize() == 1){
    		this.NumHouseLightBlue.add(new IntContainer(currentPlayer.getNumberOfHouses(currentPlayer.getLightBlueNameAt(0))));
			this.hasHotelLightBlue.add(new BooleanContainer(currentPlayer.hasHotel(currentPlayer.getLightBlueNameAt(0))));
			this.isMortgagedLightBlue.add(new BooleanContainer(currentPlayer.isMortgaged(currentPlayer.getLightBlueNameAt(0))));
			this.NumHouseLightBlue.add(new IntContainer(0));
			this.hasHotelLightBlue.add(new BooleanContainer(false));
			this.isMortgagedLightBlue.add(new BooleanContainer(false));
			this.NumHouseLightBlue.add(new IntContainer(0));
			this.hasHotelLightBlue.add(new BooleanContainer(false));
			this.isMortgagedLightBlue.add(new BooleanContainer(false));
			}
    	
    	//Now adding the ButtonPanel if the color is complete
    	for(int i = 0; i< this.currentPlayer.getLightBlueSize(); i++){
    			System.out.println("adding prop to buttonosOfpropButtons");
    			String name = currentPlayer.getLightBlueNameAt(i);
    			if(currentPlayer.isMortgaged(name) == false)
    				canMortgageSomeProp = true;
    			availableProperties.add(new ButtonsOfPropHouseHotel(currentPlayer, currentPlayer.getLightBlueSize(), i, totalGain, remainingCash,  name, currentPlayer.getNumberOfHouses(name),
    					currentPlayer.hasHotel(name), NumHouseLightBlue.get(0), NumHouseLightBlue.get(1), NumHouseLightBlue.get(2), totalGainLabel, remainingCashLabel,
    					hasHotelLightBlue.get(0), hasHotelLightBlue.get(1), hasHotelLightBlue.get(2), isMortgagedLightBlue.get(0), isMortgagedLightBlue.get(1),
    					isMortgagedLightBlue.get(2)));
    		}
    	
    	if(currentPlayer.getLightPurpleSize() == 3){
    		for(int i = 0; i < currentPlayer.getLightPurpleSize(); i++){
    				this.NumHouseLightPurple.add(new IntContainer(currentPlayer.getNumberOfHouses(currentPlayer.getLightPurpleNameAt(i))));
    				this.hasHotelLightPurple.add(new BooleanContainer(currentPlayer.hasHotel(currentPlayer.getLightPurpleNameAt(i))));
    				this.isMortgagedLightPurple.add(new BooleanContainer(currentPlayer.isMortgaged(currentPlayer.getLightPurpleNameAt(i))));
    		}
    	}
    	if(currentPlayer.getLightPurpleSize() == 2){
    		for(int i = 0; i < currentPlayer.getLightPurpleSize(); i++){
    				this.NumHouseLightPurple.add(new IntContainer(currentPlayer.getNumberOfHouses(currentPlayer.getLightPurpleNameAt(i))));
    				this.hasHotelLightPurple.add(new BooleanContainer(currentPlayer.hasHotel(currentPlayer.getLightPurpleNameAt(i))));
    				this.isMortgagedLightPurple.add(new BooleanContainer(currentPlayer.isMortgaged(currentPlayer.getLightPurpleNameAt(i))));
    				this.NumHouseLightPurple.add(new IntContainer(0));
    				this.hasHotelLightPurple.add(new BooleanContainer(false));
    				this.isMortgagedLightPurple.add(new BooleanContainer(false));
    		}
    	}
    	else if(currentPlayer.getLightPurpleSize() == 1){
    		this.NumHouseLightPurple.add(new IntContainer(currentPlayer.getNumberOfHouses(currentPlayer.getLightPurpleNameAt(0))));
			this.hasHotelLightPurple.add(new BooleanContainer(currentPlayer.hasHotel(currentPlayer.getLightPurpleNameAt(0))));
			this.isMortgagedLightPurple.add(new BooleanContainer(currentPlayer.isMortgaged(currentPlayer.getLightPurpleNameAt(0))));
			this.NumHouseLightPurple.add(new IntContainer(0));
			this.hasHotelLightPurple.add(new BooleanContainer(false));
			this.isMortgagedLightPurple.add(new BooleanContainer(false));
			this.NumHouseLightPurple.add(new IntContainer(0));
			this.hasHotelLightPurple.add(new BooleanContainer(false));
			this.isMortgagedLightPurple.add(new BooleanContainer(false));
			}
    	//Now adding the ButtonPanel if the color is complete
    	for(int i = 0; i< this.currentPlayer.getLightPurpleSize(); i++){
    			String name = currentPlayer.getLightPurpleNameAt(i);
    			if(currentPlayer.isMortgaged(name) == false)
    				canMortgageSomeProp = true;
    			availableProperties.add(new ButtonsOfPropHouseHotel(currentPlayer, currentPlayer.getLightPurpleSize(), i, totalGain, remainingCash,  name, currentPlayer.getNumberOfHouses(name),
    					currentPlayer.hasHotel(name), NumHouseLightPurple.get(0), NumHouseLightPurple.get(1), NumHouseLightPurple.get(2), totalGainLabel, remainingCashLabel,
    					hasHotelLightPurple.get(0), hasHotelLightPurple.get(1), hasHotelLightPurple.get(2), isMortgagedLightPurple.get(0), isMortgagedLightPurple.get(1),
    					isMortgagedLightPurple.get(2)));
    		}
    	
    	
    	
    	if(currentPlayer.getOrangeSize() == 3){
    		for(int i = 0; i < currentPlayer.getOrangeSize(); i++){
    				this.NumHouseOrange.add(new IntContainer(currentPlayer.getNumberOfHouses(currentPlayer.getOrangeNameAt(i))));
    				this.hasHotelOrange.add(new BooleanContainer(currentPlayer.hasHotel(currentPlayer.getOrangeNameAt(i))));
    				this.isMortgagedOrange.add(new BooleanContainer(currentPlayer.isMortgaged(currentPlayer.getOrangeNameAt(i))));
    		}
    	}
    	
    	if(currentPlayer.getOrangeSize() == 2){
    		for(int i = 0; i < currentPlayer.getOrangeSize(); i++){
    				this.NumHouseOrange.add(new IntContainer(currentPlayer.getNumberOfHouses(currentPlayer.getOrangeNameAt(i))));
    				this.hasHotelOrange.add(new BooleanContainer(currentPlayer.hasHotel(currentPlayer.getOrangeNameAt(i))));
    				this.isMortgagedOrange.add(new BooleanContainer(currentPlayer.isMortgaged(currentPlayer.getOrangeNameAt(i))));
    				this.NumHouseOrange.add(new IntContainer(0));
    				this.hasHotelOrange.add(new BooleanContainer(false));
    				this.isMortgagedOrange.add(new BooleanContainer(false));
    		}
    	}
    	else if(currentPlayer.getOrangeSize() == 1){
    		this.NumHouseOrange.add(new IntContainer(currentPlayer.getNumberOfHouses(currentPlayer.getOrangeNameAt(0))));
			this.hasHotelOrange.add(new BooleanContainer(currentPlayer.hasHotel(currentPlayer.getOrangeNameAt(0))));
			this.isMortgagedOrange.add(new BooleanContainer(currentPlayer.isMortgaged(currentPlayer.getOrangeNameAt(0))));
			this.NumHouseOrange.add(new IntContainer(0));
			this.hasHotelOrange.add(new BooleanContainer(false));
			this.isMortgagedOrange.add(new BooleanContainer(false));
			this.NumHouseOrange.add(new IntContainer(0));
			this.hasHotelOrange.add(new BooleanContainer(false));
			this.isMortgagedOrange.add(new BooleanContainer(false));
			}
    	//Now adding the ButtonPanel if the color is complete
    	for(int i = 0; i< this.currentPlayer.getOrangeSize(); i++){
    			String name = currentPlayer.getOrangeNameAt(i);
    			if(currentPlayer.isMortgaged(name) == false)
    				canMortgageSomeProp = true;
    			availableProperties.add(new ButtonsOfPropHouseHotel(currentPlayer, currentPlayer.getOrangeSize(), i, totalGain, remainingCash,  name, currentPlayer.getNumberOfHouses(name),
    					currentPlayer.hasHotel(name), NumHouseOrange.get(0), NumHouseOrange.get(1), NumHouseOrange.get(2), totalGainLabel, remainingCashLabel,
    					hasHotelOrange.get(0), hasHotelOrange.get(1), hasHotelOrange.get(2), isMortgagedOrange.get(0), isMortgagedOrange.get(1),
    					isMortgagedOrange.get(2)));
    		}
    	if(currentPlayer.getRedSize() == 3){
    		for(int i = 0; i < currentPlayer.getRedSize(); i++){
    				this.NumHouseRed.add(new IntContainer(currentPlayer.getNumberOfHouses(currentPlayer.getRedNameAt(i))));
    				this.hasHotelRed.add(new BooleanContainer(currentPlayer.hasHotel(currentPlayer.getRedNameAt(i))));
    				this.isMortgagedRed.add(new BooleanContainer(currentPlayer.isMortgaged(currentPlayer.getRedNameAt(i))));
    		}
    	}
    	
    	if(currentPlayer.getRedSize() == 2){
    		for(int i = 0; i < currentPlayer.getRedSize(); i++){
    				this.NumHouseRed.add(new IntContainer(currentPlayer.getNumberOfHouses(currentPlayer.getRedNameAt(i))));
    				this.hasHotelRed.add(new BooleanContainer(currentPlayer.hasHotel(currentPlayer.getRedNameAt(i))));
    				this.isMortgagedRed.add(new BooleanContainer(currentPlayer.isMortgaged(currentPlayer.getRedNameAt(i))));
    				this.NumHouseRed.add(new IntContainer(0));
    				this.hasHotelRed.add(new BooleanContainer(false));
    				this.isMortgagedRed.add(new BooleanContainer(false));
    		}
    	}
    	else if(currentPlayer.getRedSize() == 1){
    		this.NumHouseRed.add(new IntContainer(currentPlayer.getNumberOfHouses(currentPlayer.getRedNameAt(0))));
			this.hasHotelRed.add(new BooleanContainer(currentPlayer.hasHotel(currentPlayer.getRedNameAt(0))));
			this.isMortgagedRed.add(new BooleanContainer(currentPlayer.isMortgaged(currentPlayer.getRedNameAt(0))));
			this.NumHouseRed.add(new IntContainer(0));
			this.hasHotelRed.add(new BooleanContainer(false));
			this.isMortgagedRed.add(new BooleanContainer(false));
			this.NumHouseRed.add(new IntContainer(0));
			this.hasHotelRed.add(new BooleanContainer(false));
			this.isMortgagedRed.add(new BooleanContainer(false));
			}
    	//Now adding the ButtonPanel if the color is complete
    	for(int i = 0; i< this.currentPlayer.getRedSize(); i++){
    			String name = currentPlayer.getRedNameAt(i);
    			if(currentPlayer.isMortgaged(name) == false)
    				canMortgageSomeProp = true;
    			availableProperties.add(new ButtonsOfPropHouseHotel(currentPlayer, currentPlayer.getRedSize(), i, totalGain, remainingCash,  name, currentPlayer.getNumberOfHouses(name),
    					currentPlayer.hasHotel(name), NumHouseRed.get(0), NumHouseRed.get(1), NumHouseRed.get(2), totalGainLabel, remainingCashLabel,
    					hasHotelRed.get(0), hasHotelRed.get(1), hasHotelRed.get(2), isMortgagedRed.get(0), isMortgagedRed.get(1),
    					isMortgagedRed.get(2)));
    		}
    	if(currentPlayer.getYellowSize() == 3){
    		for(int i = 0; i < currentPlayer.getYellowSize(); i++){
    				this.NumHouseYellow.add(new IntContainer(currentPlayer.getNumberOfHouses(currentPlayer.getYellowNameAt(i))));
    				this.hasHotelYellow.add(new BooleanContainer(currentPlayer.hasHotel(currentPlayer.getYellowNameAt(i))));
    				this.isMortgagedYellow.add(new BooleanContainer(currentPlayer.isMortgaged(currentPlayer.getYellowNameAt(i))));
    		}
    	}
    	
    	if(currentPlayer.getYellowSize() == 2){
    		for(int i = 0; i < currentPlayer.getYellowSize(); i++){
    				this.NumHouseYellow.add(new IntContainer(currentPlayer.getNumberOfHouses(currentPlayer.getYellowNameAt(i))));
    				this.hasHotelYellow.add(new BooleanContainer(currentPlayer.hasHotel(currentPlayer.getYellowNameAt(i))));
    				this.isMortgagedYellow.add(new BooleanContainer(currentPlayer.isMortgaged(currentPlayer.getYellowNameAt(i))));
    				this.NumHouseYellow.add(new IntContainer(0));
    				this.hasHotelYellow.add(new BooleanContainer(false));
    				this.isMortgagedYellow.add(new BooleanContainer(false));
    		}
    	}
    	else if(currentPlayer.getYellowSize() == 1){
    		this.NumHouseYellow.add(new IntContainer(currentPlayer.getNumberOfHouses(currentPlayer.getYellowNameAt(0))));
			this.hasHotelYellow.add(new BooleanContainer(currentPlayer.hasHotel(currentPlayer.getYellowNameAt(0))));
			this.isMortgagedYellow.add(new BooleanContainer(currentPlayer.isMortgaged(currentPlayer.getYellowNameAt(0))));
			this.NumHouseYellow.add(new IntContainer(0));
			this.hasHotelYellow.add(new BooleanContainer(false));
			this.isMortgagedYellow.add(new BooleanContainer(false));
			this.NumHouseYellow.add(new IntContainer(0));
			this.hasHotelYellow.add(new BooleanContainer(false));
			this.isMortgagedYellow.add(new BooleanContainer(false));
			}
    	//Now adding the ButtonPanel if the color is complete
    	for(int i = 0; i< this.currentPlayer.getYellowSize(); i++){
    			String name = currentPlayer.getYellowNameAt(i);
    			if(currentPlayer.isMortgaged(name) == false)
    				canMortgageSomeProp = true;
    			availableProperties.add(new ButtonsOfPropHouseHotel(currentPlayer, currentPlayer.getYellowSize(), i, totalGain, remainingCash,  name, currentPlayer.getNumberOfHouses(name),
    					currentPlayer.hasHotel(name), NumHouseYellow.get(0), NumHouseYellow.get(1), NumHouseYellow.get(2), totalGainLabel, remainingCashLabel,
    					hasHotelYellow.get(0), hasHotelYellow.get(1), hasHotelYellow.get(2), isMortgagedYellow.get(0), isMortgagedYellow.get(1),
    					isMortgagedYellow.get(2)));
    		}
    	if(currentPlayer.getGreenSize() == 3){
    		System.out.println("3 grrens!");
    		for(int i = 0; i < currentPlayer.getGreenSize(); i++){
    				this.NumHouseGreen.add(new IntContainer(currentPlayer.getNumberOfHouses(currentPlayer.getGreenNameAt(i))));
    				this.hasHotelGreen.add(new BooleanContainer(currentPlayer.hasHotel(currentPlayer.getGreenNameAt(i))));
    				this.isMortgagedGreen.add(new BooleanContainer(currentPlayer.isMortgaged(currentPlayer.getGreenNameAt(i))));
    		}
    	}
    	
    	if(currentPlayer.getGreenSize() == 2){
    		for(int i = 0; i < currentPlayer.getGreenSize(); i++){
    				this.NumHouseGreen.add(new IntContainer(currentPlayer.getNumberOfHouses(currentPlayer.getGreenNameAt(i))));
    				this.hasHotelGreen.add(new BooleanContainer(currentPlayer.hasHotel(currentPlayer.getGreenNameAt(i))));
    				this.isMortgagedGreen.add(new BooleanContainer(currentPlayer.isMortgaged(currentPlayer.getGreenNameAt(i))));
    				this.NumHouseGreen.add(new IntContainer(0));
    				this.hasHotelGreen.add(new BooleanContainer(false));
    				this.isMortgagedGreen.add(new BooleanContainer(false));
    		}
    	}
    	else if(currentPlayer.getGreenSize() == 1){
    		this.NumHouseGreen.add(new IntContainer(currentPlayer.getNumberOfHouses(currentPlayer.getGreenNameAt(0))));
			this.hasHotelGreen.add(new BooleanContainer(currentPlayer.hasHotel(currentPlayer.getGreenNameAt(0))));
			this.isMortgagedGreen.add(new BooleanContainer(currentPlayer.isMortgaged(currentPlayer.getGreenNameAt(0))));
			this.NumHouseGreen.add(new IntContainer(0));
			this.hasHotelGreen.add(new BooleanContainer(false));
			this.isMortgagedGreen.add(new BooleanContainer(false));
			this.NumHouseGreen.add(new IntContainer(0));
			this.hasHotelGreen.add(new BooleanContainer(false));
			this.isMortgagedGreen.add(new BooleanContainer(false));
			}
    	//Now adding the ButtonPanel if the color is complete
    	for(int i = 0; i< this.currentPlayer.getGreenSize(); i++){
    			String name = currentPlayer.getGreenNameAt(i);
    			if(currentPlayer.isMortgaged(name) == false)
    				canMortgageSomeProp = true;
    			availableProperties.add(new ButtonsOfPropHouseHotel(currentPlayer, currentPlayer.getGreenSize(), i, totalGain, remainingCash,  name, currentPlayer.getNumberOfHouses(name),
    					currentPlayer.hasHotel(name), NumHouseGreen.get(0), NumHouseGreen.get(1), NumHouseGreen.get(2), totalGainLabel, remainingCashLabel,
    					hasHotelGreen.get(0), hasHotelGreen.get(1), hasHotelGreen.get(2), isMortgagedGreen.get(0), isMortgagedGreen.get(1),
    					isMortgagedGreen.get(2)));
    		}
    	if(currentPlayer.getDarkBlueSize() == 2){
    		for(int i = 0; i < currentPlayer.getDarkBlueSize(); i++){
    				this.NumHouseDarkBlue.add(new IntContainer(currentPlayer.getNumberOfHouses(currentPlayer.getDarkBlueNameAt(i))));
    				this.hasHotelDarkBlue.add(new BooleanContainer(currentPlayer.hasHotel(currentPlayer.getDarkBlueNameAt(i))));
    				this.isMortgagedDarkBlue.add(new BooleanContainer(currentPlayer.isMortgaged(currentPlayer.getDarkBlueNameAt(i))));
    		}
    	}
    	else if(currentPlayer.getDarkBlueSize() == 1){
    		this.NumHouseDarkBlue.add(new IntContainer(currentPlayer.getNumberOfHouses(currentPlayer.getDarkBlueNameAt(0))));
			this.hasHotelDarkBlue.add(new BooleanContainer(currentPlayer.hasHotel(currentPlayer.getDarkBlueNameAt(0))));
			this.isMortgagedDarkBlue.add(new BooleanContainer(currentPlayer.isMortgaged(currentPlayer.getDarkBlueNameAt(0))));
			this.NumHouseDarkBlue.add(new IntContainer(0));
			this.hasHotelDarkBlue.add(new BooleanContainer(false));
			this.isMortgagedDarkBlue.add(new BooleanContainer(false));
			}
    	//Now adding the ButtonPanel if the color is complete
    	for(int i = 0; i< this.currentPlayer.getDarkBlueSize(); i++){
    			String name = currentPlayer.getDarkBlueNameAt(i);
    			if(currentPlayer.isMortgaged(name) == false)
    				canMortgageSomeProp = true;
    			availableProperties.add(new ButtonsOfPropHouseHotel(currentPlayer, currentPlayer.getDarkBlueSize(), i, totalGain, remainingCash,  name, currentPlayer.getNumberOfHouses(name),
    					currentPlayer.hasHotel(name), NumHouseDarkBlue.get(0), NumHouseDarkBlue.get(1), new IntContainer(0), totalGainLabel, remainingCashLabel,
    					hasHotelDarkBlue.get(0), hasHotelDarkBlue.get(1), new BooleanContainer(false), isMortgagedDarkBlue.get(0), isMortgagedDarkBlue.get(1),
    					new BooleanContainer(false)));
    		}
    	
    	
    	//Utility
    	for(int i = 0; i < currentPlayer.getUtilitySize(); i++){
    		
			this.isMortgagedUtility.add(new BooleanContainer(currentPlayer.isMortgaged(currentPlayer.getUtilityNameAt(i))));
    	}
   
    	for(int i = 0; i < this.currentPlayer.getNumUtility(); i++){
    		String name = currentPlayer.getUtilityNameAt(i);
    		if(currentPlayer.isMortgaged(name) == false)
				canMortgageSomeProp = true;
    		availableProperties.add(new ButtonsOfPropHouseHotel(currentPlayer, i, totalGain, remainingCash, name,
    				totalGainLabel, remainingCashLabel, this.isMortgagedUtility.get(i)));
    	}
    	//railroad
    	for(int i = 0; i < currentPlayer.getRailroadSize(); i++){
			this.isMortgagedRailroad.add(new BooleanContainer(currentPlayer.isMortgaged(currentPlayer.getRailroadNameAt(i))));
    	}
    	for(int i = 0; i < this.currentPlayer.getRailroadSize(); i++){
    		String name = currentPlayer.getRailroadNameAt(i);
    		if(currentPlayer.isMortgaged(name) == false)
				canMortgageSomeProp = true;
    		availableProperties.add(new ButtonsOfPropHouseHotel(currentPlayer, i, totalGain, remainingCash, name,
    				totalGainLabel, remainingCashLabel, this.isMortgagedRailroad.get(i)));
    	}
    	
    	if(canMortgageSomeProp == false){
    		JLabel warning = new JLabel("You don't have any property to be mortgaged.");
			JOptionPane.showMessageDialog(this, warning);
			returnValue = 0;
			this.setVisible(false);
			dispose();
    	}
    	else{
    	JScrollPane scroll = new JScrollPane(availableProperties, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
    	scroll.setPreferredSize(new Dimension(400, 200));
    	
		JPanel panelWithButtons = new JPanel();
    	doIt = new JButton("Do It!");
    	cancel = new JButton("Cancel");
    	panelWithButtons.add(doIt);
    	panelWithButtons.add(cancel);
    	doIt.addActionListener(this);
        cancel.addActionListener(this);
        
        panel = new JPanel();//a panel put on the center of the border layout
    	//panel.setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
    	//panel.setBackground(Color.magenta);
        
        //create the panel with labels that shows instructions
        JPanel panelWLabel = new JPanel(new GridLayout(0,1));
    	panelWLabel.add(new JLabel("Click on the houses to sell you'd like to sell"));
    	panelWLabel.add(new JLabel("Click the checkbox to mortgage"));
    	panel.add(panelWLabel);
    	
    	panel.add(scroll);
    	//show the result of the calculation
    	JPanel showCashPanel = new JPanel();
    	showCashPanel.setLayout(new GridLayout(4, 0));
    	showCashPanel.add(new JLabel("Starting cash: $" + this.currentPlayer.getCash()));
    	showCashPanel.add(totalGainLabel);
    	showCashPanel.add(remainingCashLabel);
    	showCashPanel.add(panelWithButtons);//defined above
    	panel.add(showCashPanel);
    	panel.setVisible(true);


    	//putting them 
        setSize(450, 500);
        setModal(true);
        setLayout(new BorderLayout(0,0));
        //JLabel info = new JLabel(new ImageIcon("./menuButtons/smallProperty.JPG"));
        
        add(new JLabel(new ImageIcon("./menuButtons/buildHouseHotel.JPG")), BorderLayout.NORTH);
        add(panel, BorderLayout.CENTER);
        //add(info, BorderLayout.WEST);
        //info.setPreferredSize(new Dimension(190, 125));
        
        this.setLocationRelativeTo(null);
		this.setVisible(true);
    	}
	}
	public void updateProperties(Player p){
		//UPDATING PROPERTIES
		System.out.println("Selling houses or mortgaging prop");
		for(int i = 0; i< p.getDarkPurpleSize(); i++){
			//update the # of houses
			p.removeHouse(p.getDarkPurpleNameAt(i), p.getNumberOfHouses(p.getDarkPurpleNameAt(i)) - this.NumHouseDarkPurple.get(i).intValue());
			//mortgage the property
			if(this.isMortgagedDarkPurple.get(i).boolValue() == true){
				p.mortgage(p.getDarkPurpleNameAt(i));
			}
		}
		System.out.println("size of lightblue = " + p.getLightBlueSize());
		
		for(int i = 0; i< p.getLightBlueSize(); i++){
			//update the # of houses
			
			System.out.println(p.getLightBlueNameAt(i) +  " Initial num of houses = "+ p.getNumberOfHouses(p.getLightBlueNameAt(i)));
			System.out.println(p.getLightBlueNameAt(i) +  " After num of houses = " + this.NumHouseLightBlue.get(i).intValue());
			p.removeHouse(p.getLightBlueNameAt(i), p.getNumberOfHouses(p.getLightBlueNameAt(i)) - this.NumHouseLightBlue.get(i).intValue());
			
			//mortgage the property
			if(this.isMortgagedLightBlue.get(i).boolValue() == true){
				p.mortgage(p.getLightBlueNameAt(i));
			}
		}
		for(int i = 0; i< p.getLightPurpleSize(); i++){
			//update the # of houses
			
			p.removeHouse(p.getLightPurpleNameAt(i), p.getNumberOfHouses(p.getLightPurpleNameAt(i)) - this.NumHouseLightPurple.get(i).intValue());
			//mortgage the property
			if(this.isMortgagedLightPurple.get(i).boolValue() == true){
				p.mortgage(p.getLightPurpleNameAt(i));
			}
		}
		for(int i = 0; i< p.getOrangeSize(); i++){
			//update the # of houses
			
			p.removeHouse(p.getOrangeNameAt(i), p.getNumberOfHouses(p.getOrangeNameAt(i)) - this.NumHouseOrange.get(i).intValue());
			//mortgage the property
			if(this.isMortgagedOrange.get(i).boolValue() == true){
				p.mortgage(p.getOrangeNameAt(i));
			}
		}
		for(int i = 0; i< p.getRedSize(); i++){
			//update the # of houses
			
			p.removeHouse(p.getRedNameAt(i), p.getNumberOfHouses(p.getRedNameAt(i)) - this.NumHouseRed.get(i).intValue());
			//mortgage the property
			if(this.isMortgagedRed.get(i).boolValue() == true){
				p.mortgage(p.getRedNameAt(i));
			}
		}
		for(int i = 0; i< p.getYellowSize(); i++){
			//update the # of houses
			p.removeHouse(p.getYellowNameAt(i), p.getNumberOfHouses(p.getYellowNameAt(i)) - this.NumHouseYellow.get(i).intValue());
			//mortgage the property
			if(this.isMortgagedYellow.get(i).boolValue() == true){
				p.mortgage(p.getYellowNameAt(i));
			}
		}
		for(int i = 0; i< p.getGreenSize(); i++){
			//update the # of houses
			
			p.removeHouse(p.getGreenNameAt(i), p.getNumberOfHouses(p.getGreenNameAt(i)) - this.NumHouseGreen.get(i).intValue());
			//mortgage the property
			if(this.isMortgagedGreen.get(i).boolValue() == true){
				p.mortgage(p.getGreenNameAt(i));
			}
		}
		for(int i = 0; i< p.getDarkBlueSize(); i++){
			//update the # of houses
			String propName = new String(p.getDarkBlueNameAt(i));
			p.removeHouse(p.getDarkBlueNameAt(i), p.getNumberOfHouses(p.getDarkBlueNameAt(i)) - this.NumHouseDarkBlue.get(i).intValue());
			//mortgage the property
			if(this.isMortgagedDarkBlue.get(i).boolValue() == true){
				p.mortgage(p.getDarkBlueNameAt(i));
			}
		}
		//UPDATING Util And Railroad
		for(int i = 0; i<p.getUtilitySize(); i++){
			String propName = new String(p.getUtilityNameAt(i));
			if(this.isMortgagedUtility.get(i).boolValue() == true){
				p.mortgage(propName);
			}
		}
		for(int i = 0; i<p.getRailroadSize(); i++){
			String propName = new String(p.getRailroadNameAt(i));
			if(this.isMortgagedRailroad.get(i).boolValue() == true){
				p.mortgage(propName);
			}
		}
	}
	public void actionPerformed(ActionEvent e){
        if(e.getSource() == doIt){
        	
        	returnValue = 1;
            this.currentPlayer.addCash(this.totalGain.intValue());
                   
          //TESTPart
            System.out.println("cash after pressing doit: " + this.currentPlayer.getCash());
            for(int i = 0; i<this.currentPlayer.getDarkPurpleSize(); i++){
            	String name = this.currentPlayer.getDarkPurpleNameAt(i);
            	System.out.println(name + " has "+ this.currentPlayer.getNumberOfHouses(name));
            	System.out.println(name + " has hotel?: "+ this.currentPlayer.hasHotel(name));
            	System.out.println(name + " is mortgaged?: "+ this.currentPlayer.isMortgaged(name));
            }
            for(int i = 0; i<this.currentPlayer.getLightBlueSize(); i++){
            	String name = this.currentPlayer.getLightBlueNameAt(i);
            	System.out.println(name + " has "+ this.currentPlayer.getNumberOfHouses(name));
            	System.out.println(name + " has hotel?: "+ this.currentPlayer.hasHotel(name));
            	System.out.println(name + " is mortgaged?: "+ this.currentPlayer.isMortgaged(name));
            }
            for(int i = 0; i<this.currentPlayer.getLightPurpleSize(); i++){
            	String name = this.currentPlayer.getLightPurpleNameAt(i);
            	System.out.println(name + " has "+ this.currentPlayer.getNumberOfHouses(name));
            	System.out.println(name + " has hotel?: "+ this.currentPlayer.hasHotel(name));
            	System.out.println(name + " is mortgaged?: "+ this.currentPlayer.isMortgaged(name));
            }
            for(int i = 0; i<this.currentPlayer.getOrangeSize(); i++){
            	String name = this.currentPlayer.getOrangeNameAt(i);
            	System.out.println(name + " has "+ this.currentPlayer.getNumberOfHouses(name));
            	System.out.println(name + " has hotel?: "+ this.currentPlayer.hasHotel(name));
            	System.out.println(name + " is mortgaged?: "+ this.currentPlayer.isMortgaged(name));
            }
            for(int i = 0; i<this.currentPlayer.getRedSize(); i++){
            	String name = this.currentPlayer.getRedNameAt(i);
            	System.out.println(name + " has "+ this.currentPlayer.getNumberOfHouses(name));
            	System.out.println(name + " has hotel?: "+ this.currentPlayer.hasHotel(name));
            	System.out.println(name + " is mortgaged?: "+ this.currentPlayer.isMortgaged(name));
            }
            for(int i = 0; i<this.currentPlayer.getYellowSize(); i++){
            	String name = this.currentPlayer.getYellowNameAt(i);
            	System.out.println(name + " has "+ this.currentPlayer.getNumberOfHouses(name));
            	System.out.println(name + " has hotel?: "+ this.currentPlayer.hasHotel(name));
            	System.out.println(name + " is mortgaged?: "+ this.currentPlayer.isMortgaged(name));
            }
            for(int i = 0; i<this.currentPlayer.getGreenSize(); i++){
            	String name = this.currentPlayer.getGreenNameAt(i);
            	System.out.println(name + " has "+ this.currentPlayer.getNumberOfHouses(name));
            	System.out.println(name + " has hotel?: "+ this.currentPlayer.hasHotel(name));
            	System.out.println(name + " is mortgaged?: "+ this.currentPlayer.isMortgaged(name));
            }
            for(int i = 0; i<this.currentPlayer.getDarkBlueSize(); i++){
            	String name = this.currentPlayer.getDarkBlueNameAt(i);
            	System.out.println(name + " has "+ this.currentPlayer.getNumberOfHouses(name));
            	System.out.println(name + " has hotel?: "+ this.currentPlayer.hasHotel(name));
            	System.out.println(name + " is mortgaged?: "+ this.currentPlayer.isMortgaged(name));
            }
            for(int i = 0; i<this.currentPlayer.getUtilitySize(); i++){
            	String name = this.currentPlayer.getUtilityNameAt(i);
            	System.out.println(name + " is mortgaged?: "+ this.currentPlayer.isMortgaged(name));
            }
            for(int i = 0; i<this.currentPlayer.getRailroadSize(); i++){
            	String name = this.currentPlayer.getRailroadNameAt(i);
            	System.out.println(name + " is mortgaged?: "+ this.currentPlayer.isMortgaged(name));
            }
            
            System.out.println("total Wealth after pressing DoIt is " + this.currentPlayer.getTotalWealth());
            System.out.println("total houseNum after pressing DoIt is " + this.currentPlayer.getTotalHouseNum());
    		 //TESTPart
            
            
            updateProperties(currentPlayer);
            
          //TESTPart
            System.out.println("cash after updatebuilding: " + this.currentPlayer.getCash());
            for(int i = 0; i<this.currentPlayer.getDarkPurpleSize(); i++){
            	String name = this.currentPlayer.getDarkPurpleNameAt(i);
            	System.out.println(name + " has "+ this.currentPlayer.getNumberOfHouses(name));
            	System.out.println(name + " has hotel?: "+ this.currentPlayer.hasHotel(name));
            	System.out.println(name + " is mortgaged?: "+ this.currentPlayer.isMortgaged(name));
            }
            for(int i = 0; i<this.currentPlayer.getLightBlueSize(); i++){
            	String name = this.currentPlayer.getLightBlueNameAt(i);
            	System.out.println(name + " has "+ this.currentPlayer.getNumberOfHouses(name));
            	System.out.println(name + " has hotel?: "+ this.currentPlayer.hasHotel(name));
            	System.out.println(name + " is mortgaged?: "+ this.currentPlayer.isMortgaged(name));
            }
            for(int i = 0; i<this.currentPlayer.getLightPurpleSize(); i++){
            	String name = this.currentPlayer.getLightPurpleNameAt(i);
            	System.out.println(name + " has "+ this.currentPlayer.getNumberOfHouses(name));
            	System.out.println(name + " has hotel?: "+ this.currentPlayer.hasHotel(name));
            	System.out.println(name + " is mortgaged?: "+ this.currentPlayer.isMortgaged(name));
            }
            for(int i = 0; i<this.currentPlayer.getOrangeSize(); i++){
            	String name = this.currentPlayer.getOrangeNameAt(i);
            	System.out.println(name + " has "+ this.currentPlayer.getNumberOfHouses(name));
            	System.out.println(name + " has hotel?: "+ this.currentPlayer.hasHotel(name));
            	System.out.println(name + " is mortgaged?: "+ this.currentPlayer.isMortgaged(name));
            }
            for(int i = 0; i<this.currentPlayer.getRedSize(); i++){
            	String name = this.currentPlayer.getRedNameAt(i);
            	System.out.println(name + " has "+ this.currentPlayer.getNumberOfHouses(name));
            	System.out.println(name + " has hotel?: "+ this.currentPlayer.hasHotel(name));
            	System.out.println(name + " is mortgaged?: "+ this.currentPlayer.isMortgaged(name));
            }
            for(int i = 0; i<this.currentPlayer.getYellowSize(); i++){
            	String name = this.currentPlayer.getYellowNameAt(i);
            	System.out.println(name + " has "+ this.currentPlayer.getNumberOfHouses(name));
            	System.out.println(name + " has hotel?: "+ this.currentPlayer.hasHotel(name));
            	System.out.println(name + " is mortgaged?: "+ this.currentPlayer.isMortgaged(name));
            }
            for(int i = 0; i<this.currentPlayer.getGreenSize(); i++){
            	String name = this.currentPlayer.getGreenNameAt(i);
            	System.out.println(name + " has "+ this.currentPlayer.getNumberOfHouses(name));
            	System.out.println(name + " has hotel?: "+ this.currentPlayer.hasHotel(name));
            	System.out.println(name + " is mortgaged?: "+ this.currentPlayer.isMortgaged(name));
            }
            for(int i = 0; i<this.currentPlayer.getDarkBlueSize(); i++){
            	String name = this.currentPlayer.getDarkBlueNameAt(i);
            	System.out.println(name + " has "+ this.currentPlayer.getNumberOfHouses(name));
            	System.out.println(name + " has hotel?: "+ this.currentPlayer.hasHotel(name));
            	System.out.println(name + " is mortgaged?: "+ this.currentPlayer.isMortgaged(name));
            }
            for(int i = 0; i<this.currentPlayer.getUtilitySize(); i++){
            	String name = this.currentPlayer.getUtilityNameAt(i);
            	System.out.println(name + " is mortgaged?: "+ this.currentPlayer.isMortgaged(name));
            }
            for(int i = 0; i<this.currentPlayer.getRailroadSize(); i++){
            	String name = this.currentPlayer.getRailroadNameAt(i);
            	System.out.println(name + " is mortgaged?: "+ this.currentPlayer.isMortgaged(name));
            }
            
            System.out.println("total Wealth after pressing DoIt is " + this.currentPlayer.getTotalWealth());
            System.out.println("total houseNum after pressing DoIt is " + this.currentPlayer.getTotalHouseNum());
    		 //TESTPart
            
            
        }
        else if(e.getSource() == cancel){
        	returnValue = 0;
        }
        resetReturnValue();
        setVisible(false);
        dispose();
    }
	public int getReturnValue(){
		return returnValue;
	}
	public void resetReturnValue(){
		returnValue = -1;
	}
}
